package com.dyx.api.files.controller;


import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.expression.spel.ast.NullLiteral;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.Date;


/**
 * Created by Administrator on 2017/11/13 0027.
 */

@RestController
@RequestMapping("/appSide")
public class ControllerByZBA extends BaseController {

    @Autowired
    private Environment env;

    /*
     * 系统设置收货地址
     * */
    //系统设置--收货信息
    @RequestMapping(value = "/addReceiveInformation", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/addReceiveInformation", notes = "系统设置-收货信息-新增")
    @ApiImplicitParam(name = "param", required = true, dataType = "{\"provinceName\":\"省\"," +
            "\"cityName\":\"市\",\"areaName\":\"县区\",\"detailAddress\":\"详细地址\",\"addrCoord\":\"地址坐标\",\"addrLatitude\":\"纬度\",\"addrLinkpeople\":\"联系人\",\"addrMobile\":\"联系电话\",}")
    public String addReceiveInformation(@RequestBody JSONObject param) {
        try {
            param.put("enterpriseId", getSessionUser().getString("enterpriseId"));
            param.put("addrType", 0);
            param.put("addrDefault", 0);
            param.put("enabledStuats", 0);
            JSONObject resultData = selectOtherModule(env.getProperty("rest.AddressController"), env.getProperty("rest.AddressController.addAddress"), param);
            return resultData.toJSONString();
        } catch (Exception e) {
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }

    //设置为默认收发货地址
    @RequestMapping(value = "/defaultAddress", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/defaultAddress", notes = "系统设置-收货信息-默认地址")
    @ApiImplicitParam(name = "param", required = true, dataType = "{\"id\":\"收发货地址id\"}")
    public String setDefaultAddress(@RequestBody JSONObject param) {
        try {
            param.put("enterpriseId", getSessionUser().getString("enterpriseId"));
            JSONObject resultData = selectOtherModule(env.getProperty("rest.AddressController"), env.getProperty("rest.AddressController.defaultAddress"), param);
            return resultData.toJSONString();
        } catch (Exception e) {
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }

    //修改地址
    @RequestMapping(value = "/modifyAddress", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/modifyAddress", notes = "系统设置-收货信息-修改地址")
    @ApiImplicitParam(name = "param", required = true, dataType = "{\"id\":\"修改地址的id\"}")
    public String modifyAddress(@RequestBody JSONObject param) {
        try {
            JSONObject resultData = selectOtherModule(env.getProperty("rest.AddressController"), env.getProperty("rest.AddressController.modifyAddress"), param);
            return resultData.toJSONString();
        } catch (Exception e) {
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }

    //查询收货列表
    @RequestMapping(value = "/getReciveAddressList", method = RequestMethod.POST)
    @ApiOperation(value = "/getReciveAddressList", notes = "查询企业收货地址列表")
    public String getReciveAddressList() {
        try {
            JSONObject param =new JSONObject();
            param.put("enterpriseId", getSessionUser().getString("enterpriseId"));
            param.put("id", 1);
            JSONObject resultData = selectOtherModule(env.getProperty("rest.AddressController"), env.getProperty("rest.AddressController.getReciveAddressList"), param);
            return resultData.toJSONString();
        } catch (Exception e) {
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }

    /*
     * 系统设置发货地址
     * */
    //企业发货地址列表
    @RequestMapping(value = "/getSendAddressList", method = RequestMethod.POST)
    @ApiOperation(value = "/getSendAddressList", notes = "查询企业发货地址列表")
    public String getSendAddressList(@RequestBody JSONObject param) {
        try {
            param.put("enterpriseId", getSessionUser().getString("enterpriseId"));
            param.put("id", 1);
            JSONObject resultData = selectOtherModule(env.getProperty("rest.AddressController"), env.getProperty("rest.AddressController.getSendAddressList"), param);
            return resultData.toJSONString();
        } catch (Exception e) {
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }

    }

    //新增发货地址
    @RequestMapping(value = "/addSendAddress", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/addSendAddress", notes = "系统设置-收货信息-新增")
    @ApiImplicitParam(name = "param", required = true, dataType = "{\"provinceName\":\"省\"," +
            "\"cityName\":\"市\",\"areaName\":\"县区\",\"detailAddress\":\"详细地址\",\"addrCoord\":\"经度\",\"addrLatitude\":\"纬度\",\"addrLinkpeople\":\"联系人\",\"addrMobile\":\"联系电话\",}")
    public String addSendAddress(@RequestBody JSONObject param) {
        try {
            param.put("enterpriseId", getSessionUser().getString("enterpriseId"));
            param.put("addrType", 1);
            param.put("addrDefault", 0);
            param.put("enabledStuats", 0);
            JSONObject resultData = selectOtherModule(env.getProperty("rest.AddressController"), env.getProperty("rest.AddressController.addAddress"), param);
            return resultData.toJSONString();
        } catch (Exception e) {
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }

    /*
    * 系统设置收款账户
    * */
    //新增收款账户
    @RequestMapping(value = "/addAccount", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/addAccount", notes = "系统设置-收款账户-新增")
    @ApiImplicitParam(name = "param", value = "JSON格式企业账户对象", required = true, dataType = "{\"accountName\":\"账户名\"," +
            "\"accountBranch\":\"开通网点\",\"accountCard\":\"银行卡号\",\"accountBank\":\"所属银行\",\"accountType\":\"账户类型：0=个人账户、1=企业账户\"," +
            "\"enabledStatus\":\"启用状态：0=未启用、1=已启用\"}")
    public String addAccount(@RequestBody JSONObject param) {
        try {
            param.put("enterpriseId",getSessionUser().getString("enterpriseId"));//企业id
            param.put("accountDefault", 0);
            JSONObject resultData = selectOtherModule(env.getProperty("rest.AddressController"), env.getProperty("rest.AccountController.AccountController"), param);
            return resultData.toJSONString();
        } catch (Exception e) {
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }

    //修改收款账户
    @RequestMapping(value = "/modifyAccount", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/modifyAccount", notes = "根据id修改企业账户")
    @ApiImplicitParam(name = "param", required = true, dataType = "{\"id\":\"账户id\"}")
    public String modifyAccount(@RequestBody JSONObject param) {
        try {
            JSONObject resultData = selectOtherModule(env.getProperty("rest.AddressController"), env.getProperty("rest.AccountController.modifyAccount"), param);
            return resultData.toJSONString();
        } catch (Exception e) {
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }

    //账户列表
    @RequestMapping(value = "/findAll", method = RequestMethod.POST)
    @ApiOperation(value = "/findAll", notes = "查询企业账户")
    public String selectFindAll(@RequestBody JSONObject param) {
        try {
            param.put("enterpriseId", getSessionUser().getString("enterpriseId"));
//            param.put("id", 1);
            JSONObject resultData = selectOtherModule(env.getProperty("rest.AddressController"), env.getProperty("rest.AccountController.select"), param);
            return resultData.toJSONString();
        } catch (Exception e) {
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }
    //银行logo接口
    @RequestMapping(value = "/bankCheck", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/bankCheck", notes = "系统设置-银行卡号识别")
    @ApiImplicitParam(name = "param", required = true, dataType = "{\"accountCard\":\"银行卡号\"}")
    public String bankCheck(@RequestBody JSONObject param) {
        try {
            JSONObject resultData = selectOtherModule(env.getProperty("rest.AddressController"), env.getProperty("rest.AddressController.bankCheck"), param);
            return resultData.toJSONString();
        } catch (Exception e) {
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }

    //设置为默认账户
    @RequestMapping(value = "/defaultAccount", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/defaultAccount", notes = "系统设置-收货信息-默认账户")
    @ApiImplicitParam(name = "param", required = true, dataType = "{\"id\":\"收发货地址id\"}")
    public String setDefaultAccount(@RequestBody JSONObject param) {
        try {
            param.put("enterpriseId", getSessionUser().getString("enterpriseId"));
            JSONObject resultData = selectOtherModule(env.getProperty("rest.AddressController"), env.getProperty("rest.AddressController.defaultAccount"), param);
            return resultData.toJSONString();
        } catch (Exception e) {
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }
    /*
    * 系统设置实名认证
    * */
    //上传实名认证资料
    @RequestMapping(value = "/addRealAut", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/addRealAut", notes = "系统设置-收货信息-默认账户")
    @ApiImplicitParam(name = "param", required = true, dataType = "{" +
            "\"autName\":\"姓名\",\"autId\":\"身份证号\",\"autIdPic\":\"身份证照片\"，" +
            "\"autAuditStatus\":\"认证状态\"，" + "\"tenId\":\"租户id\"}")
    public String addRealAut(@RequestBody JSONObject param) {
        try {
            JSONObject user =getSessionUser();
            param.put("tenId",user.getString("tenId"));
            param.put("userId",user.getString("userId"));//提交人id
            param.put("userName",user.getString("userId"));//提交人名称
            param.put("tenId",user.getString("tenId"));//所属租户
            param.put("autCreatetime",getAllTime());//提交人id
            JSONObject resultData = selectOtherModule(env.getProperty("rest.UserController"), env.getProperty("rest.RealAutController.addRealAut"), param);
            return resultData.toJSONString();
        } catch (Exception e) {
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }

    //根据id查询实名认证资料
    @RequestMapping(value="/selectRealAut", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/selectRealAut" ,notes ="根据id修改实名认证资料")
    public String selectRealAut(@RequestBody JSONObject param) {
        try {
            param.put("tenId",getSessionUser().getString("tenId"));
            JSONObject resultData = selectOtherModule(env.getProperty("rest.UserController"), env.getProperty("rest.RealAutController.selectRealAut"), param);
            return resultData.toJSONString();
        }catch (Exception e){
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }

    //修改实名认证资料
    @RequestMapping(value = "/modifyRealChange", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/modifyRealChange", notes = "根据id修改资料")
    @ApiImplicitParam(name = "param", required = true, dataType = "{" + "\"realId\":\"实名认证的id\"}")
    public String modifyRealChange(@RequestBody JSONObject param) {
        try {
            param.put("changeTime", getAllTime());
            JSONObject resultData = selectOtherModule(env.getProperty("rest.UserController"), env.getProperty("rest.RealAutController.modifyRealAut"), param);
            return resultData.toJSONString();
        } catch (Exception e) {
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }

    //查询企业认证信息
    @RequestMapping(value="/selectRealEnterpriseAut", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/selectRealEnterpriseAut" ,notes ="实名认证资料")
    @ApiImplicitParam(name = "param", value = "JSON格式消息对象", required = true, dataType = "{}")
    public String selectRealEnterpriseAut(@RequestBody JSONObject param){
        try{
            param.put("enterpriseId",getSessionUser().getString("enterpriseId"));
            JSONObject resultData = selectOtherModule(env.getProperty("rest.AddressController"), env.getProperty("rest.RealEnterpriseController.selectRealEnterpriseAut"), param);
            return resultData.toJSONString();
        }catch (Exception e){
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }

    //修改企业认证信息
    @RequestMapping(value="/modifyRealEnterpriseChange", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/modifyRealEnterpriseChange" ,notes ="实名认证资料")
    @ApiImplicitParam(name = "param", value = "JSON格式消息对象", required = true, dataType = "{}")
    public String modifyRealEnterpriseChange(@RequestBody JSONObject param){
        try{
            JSONObject resultData = selectOtherModule(env.getProperty("rest.AddressController"), env.getProperty("rest.RealEnterpriseController.modifyRealEnterprise"), param);
            return resultData.toJSONString();
        }catch (Exception e){
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }

    //新增企业认证资料
    @RequestMapping(value="/addRealEnterpriseAut", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/addRealEnterpriseAut" ,notes ="实名认证资料")
    @ApiImplicitParam(name = "param", value = "JSON格式消息对象", required = true, dataType = "{}")
    public String addRealEnterpriseAut(@RequestBody JSONObject param){
        try{
            param.put("enterpriseId",getSessionUser().getString("enterpriseId"));
//            param.put("createTime",getAllTime());
            param.put("userId",getSessionUser().getString("userId"));
            param.put("userName",getSessionUser().getString("userName"));
            param.put("realState",3);
            JSONObject resultData = selectOtherModule(env.getProperty("rest.AddressController"), env.getProperty("rest.RealEnterpriseController.addRealEnterpriseAut"), param);
            return resultData.toJSONString();
        }catch (Exception e){
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }

    /*
    * 系统设置员工管理
    * */
    //新增租户员工
    @RequestMapping(value = "/addEm", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/addEm", notes = "新增员工资料")
    @ApiImplicitParam(name = "param", value = "JSON格式消息对象", required = true, dataType = "{" +
            "\"staffName\":\"姓名\",\"staffMemo\":\"备注\"，" +
            "\"staffNuber\":\"编号\"，" + "\"staffPwd\":\"密码\"," +  "\"dicRoleId\":\"角色id\"}")
    public String addEm(@RequestBody JSONObject param) {
        try {
            param.put("userTel",getSessionUser().getString("userTel"));
            param.put("qiyeId",getSessionUser().getString("enterpriseId"));
            param.put("tenId",getSessionUser().getString("tenId"));
            param.put("userAccountRole",3);
            JSONObject resultData = selectOtherModule(env.getProperty("rest.EmployeeController"), env.getProperty("rest.EmployeeController.addRealAut"), param);
            return resultData.toJSONString();
        } catch (Exception e) {
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }
    //查询权限角色列表信息
    @RequestMapping(value="/selectAllRoleList", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/selectAllRoleList" ,notes ="查询租户")
    @ApiImplicitParam(name = "param", value = "JSON格式消息对象", required = true, dataType = "{}")
    public String selectAllRoleList(@RequestBody JSONObject param){
        try{
            param.put("tenId",getSessionUser().getString("tenId"));
            JSONObject resultData = selectOtherModule(env.getProperty("rest.EmployeeController"), env.getProperty("rest.EmployeeController.selectAllEmList"), param);
            return resultData.toJSONString();
        }catch (Exception e){
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }
    //查询出所有角色列表
    @RequestMapping(value="/selectAllRoleName", method = RequestMethod.POST)
    @ApiOperation(value = "/selectAllRoleName" ,notes ="查询所有角色名称" )
    public String selectAllRoleName(@RequestBody JSONObject param){
        try{
            param.put("tenId",getSessionUser().getString("tenId"));
            JSONObject resultData = selectOtherModule(env.getProperty("rest.EmployeeController"), env.getProperty("rest.EmployeeController.selectAllRoleName"), param);
            return resultData.toJSONString();
        }catch (Exception e){
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }
    //修改租户员工信息
    @RequestMapping(value = "/updateem", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/updateem", notes = "修改员工信息")
    @ApiImplicitParam(name = "param", value = "JSON格式消息对象", required = true, dataType = "{" +
            "\"staffId\":\"员工id\"}")
    public String changeInformation(@RequestBody JSONObject param) {
        try {
            JSONObject resultData = selectOtherModule(env.getProperty("rest.EmployeeController"), env.getProperty("rest.EmployeeController.changeInformation"), param);
            return resultData.toJSONString();
        } catch (Exception e) {
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }
    //启用/禁用租户员工
    /*根据员工姓名，id更新状态*/
    @RequestMapping(value="/updatestate", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/updatestate" ,notes ="启用员工信息")
    @ApiImplicitParam(name = "param", value = "JSON格式消息对象", required = true, dataType = "{" +
            "\"staffState\":\"状态\",\"staffId\":\"員工id\"}")
    public String changeEm(@RequestBody JSONObject param){
        try {
            JSONObject resultData = selectOtherModule(env.getProperty("rest.EmployeeController"), env.getProperty("rest.EmployeeController.changeEmState"), param);
            return resultData.toJSONString();
        } catch (Exception e) {
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }
    //根据状态查询员工
    @RequestMapping(value="/selectEmWithStateList", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/selectEmWithStateList" ,notes ="查询员工信息")
    @ApiImplicitParam(name = "param", value = "JSON格式消息对象", required = true, dataType = "{" +
            "\"tenId\":\"租戶id\"}")
    public String selectEmWithStateList(@RequestBody JSONObject param){
        try {
            param.put("tenId",getSessionUser().getString("tenId"));
            JSONObject resultData = selectOtherModule(env.getProperty("rest.EmployeeController"), env.getProperty("rest.EmployeeController.selectEmWithStateList"), param);
            return resultData.toJSONString();
        } catch (Exception e) {
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }

    //租户员工密码重置
    @RequestMapping(value="/updatepwd", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/updatepwd" ,notes ="启用员工信息")
    @ApiImplicitParam(name = "param", value = "JSON格式消息对象", required = true, dataType = "{" +
            "\"staffName\":\"员工名\",\"staffId\":\"yuangongid\"}")
    public String updatePwd(@RequestBody JSONObject param){
        try {
            JSONObject resultData = selectOtherModule(env.getProperty("rest.EmployeeController"), env.getProperty("rest.EmployeeController.updateEmPwd"), param);
            return resultData.toJSONString();
        } catch (Exception e) {
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }
    //模糊查询员工
    @RequestMapping(value="/selectEmWithLike", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/selectEmWithLike" ,notes ="模糊查询员工信息")
    @ApiImplicitParam(name = "param", value = "JSON格式消息对象", required = true, dataType = "{}")
    public String selectEmWithLike(@RequestBody JSONObject param){
        try {
            JSONObject resultData = selectOtherModule(env.getProperty("rest.EmployeeController"), env.getProperty("rest.EmployeeController.selectEmReceptionWithLike"), param);
            return resultData.toJSONString();
        } catch (Exception e) {
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }
    //查询员工数和最近修改时间
    @RequestMapping(value = "/selectEmAndTime", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/selectEmAndTime", notes = "新增角色资料")
    @ApiImplicitParam(name = "param", value = "JSON格式消息对象", required = true, dataType = "{}")
    public String selectEmAndTime(@RequestBody JSONObject param) {
        try {
            param.put("tenId",getSessionUserLesseeId());
            JSONObject resultData = selectOtherModule(env.getProperty("rest.EmployeeController"), env.getProperty("rest.EmployeeController.selectEmAndTime"), param);
            return resultData.toJSONString();
        } catch (Exception e) {
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }
    /*
    * 系统设置角色权限
    * */
    //查询出所有模块列表
    @RequestMapping(value="/selectAllModel", method = RequestMethod.POST)
    @ApiOperation(value = "/selectAllModel" ,notes ="查询所有模块列表" )
    public String selectAllModel(@RequestBody JSONObject param){
        try{
            param.put("dicIndex","1");
            JSONObject resultData = selectOtherModule(env.getProperty("rest.EmployeeController"), env.getProperty("rest.EmployeeController.selectAllModel"), param);
            return resultData.toJSONString();
        }catch (Exception e){
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }

    //查询出所有权限列表
    @RequestMapping(value="/selectAllRole", method = RequestMethod.POST)
    @ApiOperation(value = "/selectAllRole" ,notes ="查询所有权限列表" )
    public String selectAllRole(@RequestBody JSONObject param){
        try{
            JSONObject resultData = selectOtherModule(env.getProperty("rest.EmployeeController"), env.getProperty("rest.EmployeeController.selectAllRole"), param);
            return resultData.toJSONString();
        }catch (Exception e){
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }

    //新增角色权限
    @RequestMapping(value = "/insertrole", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/insertrole", notes = "新增角色资料")
    @ApiImplicitParam(name = "param", value = "JSON格式消息对象", required = true, dataType = "{}")
    public String insertRole(@RequestBody JSONObject param) {
        try {
            param.put("dicRoleCretetime",getAllTime());
            param.put("tenId",getSessionUserLesseeId());
            JSONObject resultData = selectOtherModule(env.getProperty("rest.EmployeeController"), env.getProperty("rest.EmployeeController.insertRole"), param);
            return resultData.toJSONString();
        } catch (Exception e) {
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }
    //查询角色数和最近修改时间
    @RequestMapping(value = "/selectRoleAndTime", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/selectRoleAndTime", notes = "新增角色资料")
    @ApiImplicitParam(name = "param", value = "JSON格式消息对象", required = true, dataType = "{}")
    public String selectRoleAndTime(@RequestBody JSONObject param) {
        try {
            param.put("tenId",getSessionUserLesseeId());
            JSONObject resultData = selectOtherModule(env.getProperty("rest.EmployeeController"), env.getProperty("rest.EmployeeController.selectRoleAndTime"), param);
            return resultData.toJSONString();
        } catch (Exception e) {
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }

    //根据条件查询权限角色列表信息
    @RequestMapping(value="/selectrole", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/selectrole" ,notes ="查询租户")
    @ApiImplicitParam(name = "param", value = "JSON格式消息对象", required = true, dataType = "{}")
    public String getRole(@RequestBody JSONObject param){
        try{
            param.put("tenId",getSessionUserLesseeId());
            JSONObject resultData = selectOtherModule(env.getProperty("rest.EmployeeController"), env.getProperty("rest.EmployeeController.selectAllRoleList"), param);
            return resultData.toJSONString();
        }catch (Exception e){
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }

    //修改租户角色权限设置
    @RequestMapping(value="/updaterole", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/updaterole" ,notes ="修改租户")
    @ApiImplicitParam(name = "param", value = "JSON格式消息对象", required = true, dataType = "{}")
    public String updateRole(@RequestBody JSONObject param){
        try{
            //根据角色id修改角色名称
            JSONObject resultData = selectOtherModule(env.getProperty("rest.EmployeeController"), env.getProperty("rest.EmployeeController.updaterole"), param);
            return resultData.toJSONString();
        }catch (Exception e){
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }

    //删除角色权限列表
    @RequestMapping(value="/delectrole", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/delectrole" ,notes ="删除租户")
    @ApiImplicitParam(name = "param", value = "JSON格式消息对象", required = true, dataType = "{" +
            "\"dicRoleId\":\"权限表\"}")
    public String delectRole(@RequestBody JSONObject param){
        try{
            JSONObject resultData = selectOtherModule(env.getProperty("rest.EmployeeController"), env.getProperty("rest.EmployeeController.delectrole"), param);
            return resultData.toJSONString();
        }catch (Exception e){
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }

    //更新行业和渠道类型
    @RequestMapping(value = "/addTenIndustry", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/addTenIndustry", notes = "更新行业和渠道类型")
    @ApiImplicitParam(name = "params", value = "JSON格式消息对象", required = true, dataType = "{" +
            "\"userId\":\"用户id\" ,"+ "\"tenChannel\":\"渠道\"，"+ "\"tenIndustry\": \"企业\"" +
            "\"fristLevelModule\":\"一级分类\" ,"+"\"twoLevelModule\":\"二级分类\"}")
    public String addTenIndustry(@RequestBody JSONObject param) {
        try {
            param.put("userId",getSessionUser().getString("userId"));
            param.put("userShowId",getSessionUser().getString("userShowId"));
            JSONObject resultData = selectOtherModule(env.getProperty("rest.UserController"), env.getProperty("rest.RealAutController.addTenIndustry"), param);
            return resultData.toJSONString();
        } catch (Exception e) {
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }

    //注册保存基本资料
    @RequestMapping(value="/addBaseInformation", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/addBaseInformation" ,notes ="注册基本资料")
    @ApiImplicitParam(name = "param", value = "JSON格式企业基本信息对象", required = true, dataType = "{\"entLinkpeople\":\"联系人\"," +
            "\"entMobile\":\"手机号\",\"entName\":\"企业名称\",\"entAddress\":\"地址\",\"lesseeId\":\"所属租户id\",\"lesseeName\":\"所属租户name\"," +
            "\"entCoord\":\"地址坐标\",\"setEntCheckstatus\":\"审核状态\"}")
    public String addBaseInformation(@RequestBody JSONObject param,HttpServletRequest request){
        //0 零售商 1 批发商 2 品牌厂商   tenChannel 渠道类型
        try{
            ServletRequest request1 = (ServletRequest)request;
            String ip = request1.getRemoteAddr();
            param.put("tenChannel",getSessionUser().getString("tenChannel"));
            param.put("sumbitTime",getAllTime());
            param.put("registCity",getAddrName(request1));
            param.put("ip",getPublicIP(request1));
            JSONObject resultData = selectOtherModule(env.getProperty("rest.AddressController"), env.getProperty("rest.EnteerpriseController.addBaseInformation"), param);
            return resultData.toJSONString();
        }catch (Exception e){
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }
    //查询省
    @RequestMapping(value="/getAllPriovinceName", method = RequestMethod.POST)
    @ApiOperation(value = "/getAllPriovinceName" ,notes ="查询全部省市列表" )
    public String getAllPriovinceName(@RequestBody JSONObject param) {
        try {
            JSONObject resultData = selectOtherModule(env.getProperty("rest.AddressController"), env.getProperty("rest.PositionController.getAllPriovinceName"), param);
            return resultData.toJSONString();
        } catch (Exception e) {
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }
    //查询市
    @RequestMapping(value="/getAllCityName", method = RequestMethod.POST)
    @ApiOperation(value = "/getAllCityName" ,notes ="查询全部省市列表" )
    public String getAllCityName(@RequestBody JSONObject param) {
        try {
            JSONObject resultData = selectOtherModule(env.getProperty("rest.AddressController"), env.getProperty("rest.PositionController.getAllCityName"), param);
            return resultData.toJSONString();
        } catch (Exception e) {
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }

    //查询区
    @RequestMapping(value="/getAllCountryName", method = RequestMethod.POST)
    @ApiOperation(value = "/getAllCountryName" ,notes ="查询全部省市列表" )
    public String getAllCountryName(@RequestBody JSONObject param) {
        try {
            JSONObject resultData = selectOtherModule(env.getProperty("rest.AddressController"), env.getProperty("rest.PositionController.getAllCountryName"), param);
            return resultData.toJSONString();
        } catch (Exception e) {
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }

    //首页
    @RequestMapping(value="/selectDefaultAddress", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/selectDefaultAddress" ,notes ="查询默认收发货地址")
    @ApiImplicitParam(name = "param", value = "JSON格式手法地址id", required = true, dataType = "{}")
    public String selectDefaultAddress(@RequestBody JSONObject param) {
        try{
            param.put("enterpriseId",getSessionUser().getString("enterpriseId"));
            param.put("tenChannel",getSessionUser().getString("tenChannel"));
            JSONObject resultData = selectOtherModule(env.getProperty("rest.AddressController"), env.getProperty("rest.AddressController.selectDefaultAddress"), param);
            return resultData.toJSONString();
        }catch (Exception e){
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }

    //首页查询员工管理实名认证，登陆信息
    @RequestMapping(value="/selectInformationWithFrist", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/selectInformationWithFrist" ,notes ="首页查询员工管理实名认证，登陆信息")
    @ApiImplicitParam(name = "param", value = "JSON格式消息对象", required = true, dataType = "{}")
    public String selectInformationWithFrist(@RequestBody JSONObject param){
        try {
            param.put("tenId",getSessionUserLesseeId());
            JSONObject resultData = selectOtherModule(env.getProperty("rest.UserController"), env.getProperty("rest.UserController.selectInformationWithFrist"), param);
            return resultData.toJSONString();
        } catch (Exception e) {
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }

    @RequestMapping(value="/selectIndustrieByRegister", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/selectIndustrieByRegister" ,notes ="注册-查询行业")
    @ApiImplicitParam(name = "param", required = true, dataType = "{}")
    public String selectIndustrieByRegister(@RequestBody JSONObject param){
        try{
            JSONObject resultData = selectOtherModule(env.getProperty("rest.IndustrieConroller"),env.getProperty("rest.IndustrieBaseinfoController.getListByUserSide"),param);
            return resultData.toJSONString();
        }catch (Exception e){
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }

    //获取经营品牌信息
    @RequestMapping(value="/selectPlatformBrand", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/selectPlatformBrand" ,notes ="查询经营品牌")
    public String selectPlatformBrand(@RequestBody JSONObject param) {
        try {
            JSONObject resultData = selectOtherModule(env.getProperty("rest.BrandController"), env.getProperty("rest.PlatformBrandController.findAll"), param);
            return resultData.toJSONString();
        } catch (Exception e) {
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }
    //修改密码
    @RequestMapping(value="/retrievalpwd", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/retrievalpwd" ,notes ="修改密码")
    @ApiImplicitParam(name = "param", value = "JSON格式消息对象", required = true, dataType = "{" +
            "\"phone\":\"手机号\",\"pwds\":\"旧密码\",\"password\":\"新密码\",\"pwd\":\"新密码\"}")
    public String RetrievalPwd(@RequestBody JSONObject param) {
        try {
            JSONObject user =getSessionUser();
            param.put("phone",user.getString("phone"));
            JSONObject resultData = selectOtherModule(env.getProperty("rest.UserController"), env.getProperty("rest.UserController.retrievalpwd"), param);
            return resultData.toJSONString();
        } catch (Exception e) {
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }


    /*-----------------------系统设置-----------------------------------*/
    //退出登录接口
    @RequestMapping(value="/exitLogin", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/exitLogin" ,notes ="退出登录")
    @ApiImplicitParam(name = "param", value = "JSON格式消息对象", required = true, dataType = "{}")
    public String exitLogin(@RequestBody JSONObject param){
        try {
            param.put("userId",getSessionUser().getString("userId"));
            param.put("userAccountRole",getSessionUser().getString("userAccountRole"));
            if (param.getString("userAccountRole").equals("1")){
                param.put("staffId",getSessionUser().getString("staffId"));
            }
            JSONObject resultData = selectOtherModule(env.getProperty("rest.UserController"), env.getProperty("rest.LoginDetailsController.logindetail.exitLogin"), param);
            return resultData.toJSONString();
        } catch (Exception e) {
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }

    //意见反馈接口
    @RequestMapping(value="/feedback", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/feedback" ,notes ="退出登录")
    @ApiImplicitParam(name = "param", value = "JSON格式消息对象", required = true, dataType = "{}")
    public String insertFeedback(@RequestBody JSONObject param){
        try {
            JSONObject resultData = selectOtherModule(env.getProperty("rest.UserController"), env.getProperty("rest.LoginDetailsController.feedback"), param);
            return resultData.toJSONString();
        } catch (Exception e) {
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }


    //软件更新接口
    @RequestMapping(value="/softwareUpdate", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "/softwareUpdate" ,notes ="退出登录")
    @ApiImplicitParam(name = "param", value = "JSON格式消息对象", required = true, dataType = "{}")
    public String softwareUpdate(@RequestBody JSONObject param){
        try {
            JSONObject resultData = selectOtherModule(env.getProperty("rest.UserController"), env.getProperty("rest.LoginDetailsController.logindetail.softwareUpdate"), param);
            return resultData.toJSONString();
        } catch (Exception e) {
            e.printStackTrace();
            return returnErrorMessage("服务器繁忙,请稍后重试!");
        }
    }

}
